package com.az.zhaotao.wxqf;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;

import com.az.zhaotao.wxqf.util.SharedHelper;
import com.az.zhaotao.wxqf.util.SystemEnum;

import java.util.Map;

/**
 * Created by ZhaoTao on 2017/12/13.
 */

public class SettingActivity  extends Activity {

    private EditText editText;
    private SharedHelper sh;
    private Context mContext;
    private Button submitButton;
    private Button returnButton;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        mContext = getApplicationContext();
        sh = new SharedHelper(mContext);

        editText = findViewById(R.id.editText);
        submitButton = findViewById(R.id.title_button_forward);
        returnButton = findViewById(R.id.title_button_backward);


        submitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sh.save(SystemEnum.EditText.getKey(),editText.getText().toString());
                Toast.makeText(mContext, "已保存群发内容", Toast.LENGTH_SHORT).show();
                SettingActivity.this.finish();
            }
        });

        returnButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SettingActivity.this.finish();
            }
        });



    }

    @Override
    protected void onStart() {
        super.onStart();
        Map<String,?> data = sh.read();
        editText.setText((String) data.get(SystemEnum.EditText.getKey()));
    }
}
